CopyAttrsPlus_v2.dxl

I was wondering how you would modify the attached script "CopyAttrsPlus_v2.dxl" so that when it updates/copies an attribute it also copies the attributes descriptions "setDescription"? Thank you.

-Jim
SystemAdmin - Mon Jan 16 08:47:38 EST 2012

Re: CopyAttrsPlus_v2.dxl
Tony_Goodman - Mon Jan 16 09:15:39 EST 2012

See attached.

line 427 has been added.

Tony Goodman, www.smartdxl.com
Attachments

attachment_14778627_CopyAttrsPlus_v2A1A.dxl

Re: CopyAttrsPlus_v2.dxl
SystemAdmin - Mon Jan 16 10:11:44 EST 2012

Tony_Goodman - Mon Jan 16 09:15:39 EST 2012
See attached.

line 427 has been added.

Tony Goodman, www.smartdxl.com

Thank you for your quick reply.

I have another question regarding the script, how would you modify "bool modifyAtt(Module destMod, AttrDef ad)" so that it will also copy the Description and also correct the datatype name to match? I tried using the following code be keep getting an DXL error. What am I doing wrong and is there a best way of executing it? Thank you.
 

ad = find(m, "_IV&V ASW Req")
    if(ad != null)
        {
                OldType = find(m, ad.typeName)
                modify (ad, setDescription, "IV&V Requirement Type")
                modify (OldType, "_IV&V Req Type List", ErrMess)
                if (!null ErrMess) { print "Error: " ErrMess "\n"}
        }

Re: CopyAttrsPlus_v2.dxl
SystemAdmin - Mon Jan 16 11:16:43 EST 2012

SystemAdmin - Mon Jan 16 10:11:44 EST 2012

Thank you for your quick reply.

I have another question regarding the script, how would you modify "bool modifyAtt(Module destMod, AttrDef ad)" so that it will also copy the Description and also correct the datatype name to match? I tried using the following code be keep getting an DXL error. What am I doing wrong and is there a best way of executing it? Thank you.
 

ad = find(m, "_IV&V ASW Req")
    if(ad != null)
        {
                OldType = find(m, ad.typeName)
                modify (ad, setDescription, "IV&V Requirement Type")
                modify (OldType, "_IV&V Req Type List", ErrMess)
                if (!null ErrMess) { print "Error: " ErrMess "\n"}
        }

Thank you for your quick reply.

I added the following code to modify existing attributes. My objective is to have the Description and also the datatype name to match my master Attribute. Is there a better way of modifying the code? I believe the code already has save guards against changing the datatype name if it already exists for another attribute but I want to make sure so data is not lost. Thank you.

-Jim
 

//=================================================================================================
// Modifies an attribute definition in the to module based on
// the attribute definition in the from module
//
// Called by: copyAtts
//
// Calls: none
//
bool modifyAtt(Module destMod, AttrDef ad) {
    AttrDef destAttDef
    current = destMod
// PATCH BY JME
    string ErrMess = ""
// END PATCH BY JME
 
    AttrDef__ destAd = attribute ad.name
 
    destAttDef = find(destMod, ad.name)
    if (null(destAttDef)) return false
        
// PATCH BY JME
        AttrType OldType = find(destMod, destAttDef.typeName)
        if (!OldType.system) // verify that it's a custom datatype
        { 
                if (destAttDef.typeName != ad.typeName)
                {
                        modify (OldType, ad.typeName, ErrMess)
                                if (!null ErrMess) { errorBox(ErrMess)}
                }
        }
                
        modify (destAttDef, setDescription, ad.description)
// END PATCH BY JME
 
    if (ad.object) destAttDef = modify(destAttDef, setObject, true)
    else destAttDef = modify(destAttDef, setObject, false)
 
    if (ad.module) destAttDef = modify(destAttDef, setModule, true)
    else destAttDef = modify(destAttDef, setModule, false)
 
    if (ad.nohistory) destAttDef = modify(destAttDef, setHistory, false)
    else destAttDef = modify(destAttDef, setHistory, true)
 
    if (ad.nochanges) destAttDef = modify(destAttDef, setDates, false)
    else destAttDef = modify(destAttDef, setDates, true)
 
    if (ad.nobars)  destAttDef = modify(destAttDef, setBars, false)
    else destAttDef = modify(destAttDef, setBars, true)
 
    if (ad.multi) destAttDef = modify(destAttDef, setMulti, true)
    else destAttDef = modify(destAttDef, setMulti, false)
 
    if (ad.inherit) destAttDef = modify(destAttDef, setInherit, true)
    else destAttDef = modify(destAttDef, setInherit, false)
 
    if (ad.hidden) destAttDef = modify(destAttDef, setHidden, true)
    else destAttDef = modify(destAttDef, setHidden, false)
 
    if (ad.dxl) destAttDef = modify(destAttDef, setDXL, ad.dxl)
 
    if (ad.defval) destAttDef = modify(destAttDef, setDefault, ad.defval)
 
    //modify access rights if option set to true
    if(get(accessOptnDBE)==true) modADAccess(srcMod, destMod, ad, destAttDef)
 
    return true
} // modifyAtt